package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.declare.cebProduct.request.CebProductQueryRequest;
import com.dwms.entity.declare.cebProduct.request.CebProductRequest;
import com.dwms.entity.declare.cebProduct.response.CebProductResponse;
import com.dwms.feign.declare.CebProductFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: CebProductController
 * @Description: CebProduct
 * @Create 2025-09-06 14:18:21
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "商品备案信息")
@RestController
@RequestMapping(value = "/declare/product")
@RequiredArgsConstructor
public class CebProductController {

    private final HttpServletRequest request;
    private final CebProductFeignClient cebProductFeignClient;

    /**
     * 保存
     *
     * @param cebProductRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "保存")
    @PostMapping("/save")
    public Result save(@RequestBody CebProductRequest cebProductRequest) {
        WebUtil.getAdminRequest(request,cebProductRequest);
        return cebProductFeignClient.save(cebProductRequest);
    }

    /**
     * 修改
     *
     * @param cebProductRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result update(@RequestBody CebProductRequest cebProductRequest) {
        WebUtil.getAdminRequest(request,cebProductRequest);
        return cebProductFeignClient.update(cebProductRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebProductResponse>> findPage(@RequestBody CebProductQueryRequest query) {
        WebUtil.getAdminRequest(request,query);
        return cebProductFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebProductFeignClient.findById(query);
    }

    /**
     * 删除
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "删除")
    @PostMapping("/delete")
    public Result delete(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebProductFeignClient.delete(query);
    }

}
